import request from './index';

/**
 * 获取订单列表
 */
export function getOrders(params) {
  return request({
    url: '/order/page',
    method: 'get',
    params
  });
}

/**
 * 获取订单详情
 */
export function getOrderById(id) {
  return request({
    url: `/order/${id}`,
    method: 'get'
  });
}

/**
 * 获取我的购买订单
 */
export function getMyBuyOrders() {
  return request({
    url: '/order/my/buy',
    method: 'get'
  });
}

/**
 * 获取我的销售订单
 */
export function getMySellOrders() {
  return request({
    url: '/order/my/sell',
    method: 'get'
  });
}

/**
 * 创建订单
 */
export function createOrder(data) {
  return request({
    url: '/order',
    method: 'post',
    data
  });
}

/**
 * 支付订单
 */
export function payOrder(id) {
  return request({
    url: `/order/${id}/pay`,
    method: 'put'
  });
}

/**
 * 发货
 */
export function shipOrder(id) {
  return request({
    url: `/order/${id}/ship`,
    method: 'put'
  });
}

/**
 * 确认收货
 */
export function receiveOrder(id) {
  return request({
    url: `/order/${id}/receive`,
    method: 'put'
  });
}

/**
 * 取消订单
 */
export function cancelOrder(id) {
  return request({
    url: `/order/${id}/cancel`,
    method: 'put'
  });
} 